import { defineStore } from "./defineStore";
 //import { defineStore } from "pinia";
import { ref, computed } from "vue"
 //import goods from "./goods";
// const store = goods() //写在这里会报错
export default defineStore("userStore", {
  state() {
    return {
      count: 1000,
      //age:300 
    };
  },
  getters: {
    doubleAge() {
      //  const store = goods() //正确
      return this.count * 2
    }
  },
  actions: {
    async handleClick(value) {
      //  const store = goods() //正确
      this.count += value
      throw "errsososoo"
    }
  }
});
//推荐用第二种方式(组合式的写法)
// export default defineStore("userStore", () => {
//   //  const store = goods() //正确
//    const count = ref(60)
//   const doubleAge = computed(() => count.value * 2)
//   const handleClick = (value) => {
//     count.value += value
//   }
//   return { count, doubleAge, handleClick }
// });
